import { defineStore } from "pinia";
import { ref, computed } from "vue";
//第二个参数类型为Option对象 类似于vue2 vuex
// export const useCountStore = defineStore("count", {
//     state: () => ({
//         count: 0
//     }),
//     actions: {
//         increment() {
//             this.count++
//         }
//     },
//     getters: {
//         double: (state: any) => state.count * 2,
//     }
// })
//第二个参数类型为setup函数
export const useCountStore = defineStore("count", () => {
    const count = ref(0);
    const double = computed(() => count.value * 2);
    function increment() {
        count.value++
    }
    return {
        count, double, increment
    }
})